/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListaAtributos.java
 *
 * Created on 17/10/2011, 21:00:25
 */
package projetosustentabilidade;

import connectionBD.mySQLconsultas;
import connectionBD.retornoBD;
import java.awt.TrayIcon.MessageType;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

/**
 *
 * @author Diego
 */
public class ListaAtributos extends javax.swing.JFrame {

    private mySQLconsultas consultas;
    private ArrayList<String> listaPaisesSelecionados;

    /** Creates new form ListaAtributos */
    public ListaAtributos() {
        initComponents();
        consultas = new mySQLconsultas();
    }

    public ListaAtributos(ArrayList<String> listaPaisesSelecionadosParam) {
        initComponents();
        consultas = new mySQLconsultas();
        listaPaisesSelecionados = listaPaisesSelecionadosParam;
        preencheListaPaises(listaPaisesSelecionadosParam);
    }

    private void preencheListaPaises(ArrayList<String> listaPaisesSelecionadosParam) {
        DefaultListModel modelListaNomePaises = new DefaultListModel();

        for (String nomePais : listaPaisesSelecionadosParam) {
            modelListaNomePaises.addElement(nomePais);
        }

        jli_paisesSelecionados.setModel(modelListaNomePaises);
    }

    private ArrayList<String> getAtributosAmbientaisSelecionados() {
        ArrayList<String> atributosAmbientaisSelecionados = new ArrayList<String>();
        Object[] nomeSelecionadosNaLista = jli_ambiental.getSelectedValues();

        for (Object o : nomeSelecionadosNaLista) {
            atributosAmbientaisSelecionados.add((String) o);
        }
        return atributosAmbientaisSelecionados;
    }

    private ArrayList<String> getAtributosSociaisSelecionados() {
        ArrayList<String> atributosSocialSelecionados = new ArrayList<String>();
        Object[] nomeSelecionadosNaLista = jli_social.getSelectedValues();

        for (Object o : nomeSelecionadosNaLista) {
            atributosSocialSelecionados.add((String) o);
        }
        return atributosSocialSelecionados;
    }

    private ArrayList<String> getAtributosEconomicosSelecionados() {
        ArrayList<String> atributosEconomicosSelecionados = new ArrayList<String>();
        Object[] nomeSelecionadosNaLista = jli_economico.getSelectedValues();

        for (Object o : nomeSelecionadosNaLista) {
            atributosEconomicosSelecionados.add((String) o);
        }
        return atributosEconomicosSelecionados;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jDialog1 = new javax.swing.JDialog();
        jButton12 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jb_ambientalTodos = new javax.swing.JButton();
        jb_ambientalNenhum = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jli_ambiental = new javax.swing.JList();
        jLabel4 = new javax.swing.JLabel();
        jb_socialTodos = new javax.swing.JButton();
        jb_socialNenhum = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jli_social = new javax.swing.JList();
        jLabel5 = new javax.swing.JLabel();
        jb_economicoTodos = new javax.swing.JButton();
        jb_economicoNenhum = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jli_economico = new javax.swing.JList();
        jbt_voltar = new javax.swing.JButton();
        jbt_avancar = new javax.swing.JButton();
        jb_ambientalDescricao = new javax.swing.JButton();
        jb_socialDescricao = new javax.swing.JButton();
        jb_economicoDescricao = new javax.swing.JButton();
        jchb_graficoLinha = new javax.swing.JCheckBox();
        jchb_graficoPCA = new javax.swing.JCheckBox();
        jScrollPane4 = new javax.swing.JScrollPane();
        jli_paisesSelecionados = new javax.swing.JList();

        jDialog1.setResizable(false);

        jButton12.setText("OK");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Descrição do Atributo");

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog1Layout.createSequentialGroup()
                .addGap(149, 149, 149)
                .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                .addGap(174, 174, 174))
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addGap(120, 120, 120)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(139, 139, 139))
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                .addGap(50, 50, 50))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setText("Selecione os Atributos");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel3.setForeground(new java.awt.Color(0, 153, 0));
        jLabel3.setText("Ambiental");

        jb_ambientalTodos.setText("Todos");
        jb_ambientalTodos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_ambientalTodosActionPerformed(evt);
            }
        });

        jb_ambientalNenhum.setText("Nenhum");
        jb_ambientalNenhum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_ambientalNenhumActionPerformed(evt);
            }
        });

        jli_ambiental.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Emissão de CO2", "Emissão de SO2", "Emissão de CO2", "Área Florestal" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(jli_ambiental);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel4.setForeground(new java.awt.Color(255, 0, 0));
        jLabel4.setText("Social");

        jb_socialTodos.setText("Todos");
        jb_socialTodos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_socialTodosActionPerformed(evt);
            }
        });

        jb_socialNenhum.setText("Nenhum");
        jb_socialNenhum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_socialNenhumActionPerformed(evt);
            }
        });

        jli_social.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Expectativa de Vida", "Renda de Subsistência", "Mortalidade Infantil", "HIV" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(jli_social);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setForeground(new java.awt.Color(0, 0, 204));
        jLabel5.setText("Econômico");

        jb_economicoTodos.setText("Todos");
        jb_economicoTodos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_economicoTodosActionPerformed(evt);
            }
        });

        jb_economicoNenhum.setText("Nenhum");
        jb_economicoNenhum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_economicoNenhumActionPerformed(evt);
            }
        });

        jli_economico.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Exportação", "Importação", "Inflação", "PIB", "Preço da Gasolina" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane3.setViewportView(jli_economico);

        jbt_voltar.setText("Voltar");
        jbt_voltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbt_voltarActionPerformed(evt);
            }
        });

        jbt_avancar.setText("Avançar");
        jbt_avancar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbt_avancarActionPerformed(evt);
            }
        });

        jb_ambientalDescricao.setText("Descrição");
        jb_ambientalDescricao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_ambientalDescricaoActionPerformed(evt);
            }
        });

        jb_socialDescricao.setText("Descrição");
        jb_socialDescricao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_socialDescricaoActionPerformed(evt);
            }
        });

        jb_economicoDescricao.setText("Descricão");
        jb_economicoDescricao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_economicoDescricaoActionPerformed(evt);
            }
        });

        jchb_graficoLinha.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jchb_graficoLinha.setText("Gráfico Linha");

        jchb_graficoPCA.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jchb_graficoPCA.setText("Gráfico PCA");

        jScrollPane4.setViewportView(jli_paisesSelecionados);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jb_ambientalDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                                        .addGap(123, 123, 123)
                                        .addComponent(jb_ambientalTodos, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jb_ambientalNenhum, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))
                                    .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addGap(30, 30, 30)
                                        .addComponent(jb_socialDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                                        .addGap(124, 124, 124)
                                        .addComponent(jb_socialTodos, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jb_socialNenhum, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))
                                    .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jb_economicoDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                                        .addGap(120, 120, 120)
                                        .addComponent(jb_economicoTodos, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jb_economicoNenhum, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 406, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(45, 45, 45)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(31, 31, 31))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(163, 163, 163)
                        .addComponent(jbt_avancar, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbt_voltar, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jchb_graficoPCA)
                        .addGap(18, 18, 18)
                        .addComponent(jchb_graficoLinha)
                        .addGap(47, 47, 47)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(15, 15, 15)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jb_ambientalTodos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jb_ambientalNenhum, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3)
                                .addComponent(jb_ambientalDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                        .addGap(31, 31, 31)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jb_socialTodos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jb_socialNenhum, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jb_socialDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
                        .addGap(29, 29, 29)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jb_economicoTodos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jb_economicoNenhum, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jb_economicoDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                        .addGap(17, 17, 17))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 404, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbt_avancar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbt_voltar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jchb_graficoPCA)
                    .addComponent(jchb_graficoLinha))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        jDialog1.setVisible(false);
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jb_ambientalDescricaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_ambientalDescricaoActionPerformed

        ArrayList<String> listaAtributosAmbientaisSelecionados = getAtributosAmbientaisSelecionados();


        if (listaAtributosAmbientaisSelecionados.size() > 0) {
            for (String s : listaAtributosAmbientaisSelecionados) {
                JOptionPane.showMessageDialog(null, consultas.getDescricaoAtributo(s), s, JOptionPane.INFORMATION_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Selecione um ou mais indice(s) para ver informações sobre ele(s)");
        }


    }//GEN-LAST:event_jb_ambientalDescricaoActionPerformed

    private void jb_socialDescricaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_socialDescricaoActionPerformed

        ArrayList<String> listaAtributosSociaisSelecionados = getAtributosSociaisSelecionados();

        if (listaAtributosSociaisSelecionados.size() > 0) {
            for (String s : listaAtributosSociaisSelecionados) {
                JOptionPane.showMessageDialog(null, consultas.getDescricaoAtributo(s), s, JOptionPane.INFORMATION_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Selecione um ou mais indice(s) para ver informações sobre ele(s)");
        }

    }//GEN-LAST:event_jb_socialDescricaoActionPerformed

    private void jb_economicoDescricaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_economicoDescricaoActionPerformed

        ArrayList<String> listaAtributosEconomicosSelecionados = getAtributosEconomicosSelecionados();

        if (listaAtributosEconomicosSelecionados.size() > 0) {
            for (String s : listaAtributosEconomicosSelecionados) {
                JOptionPane.showMessageDialog(null, consultas.getDescricaoAtributo(s), s, JOptionPane.INFORMATION_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Selecione um ou mais indice(s) para ver informações sobre ele(s)");
        }
    }//GEN-LAST:event_jb_economicoDescricaoActionPerformed

    private void jbt_voltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbt_voltarActionPerformed
        this.dispose();
    }//GEN-LAST:event_jbt_voltarActionPerformed

    private void jb_ambientalTodosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_ambientalTodosActionPerformed
        int[] x = {0, 1, 2, 3};
        jli_ambiental.setSelectedIndices(x);

    }//GEN-LAST:event_jb_ambientalTodosActionPerformed

    private void jb_socialTodosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_socialTodosActionPerformed
        int[] x = {0, 1, 2, 3};
        jli_social.setSelectedIndices(x);
    }//GEN-LAST:event_jb_socialTodosActionPerformed

    private void jb_economicoTodosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_economicoTodosActionPerformed
        int[] x = {0, 1, 2, 3, 4};
        jli_economico.setSelectedIndices(x);
    }//GEN-LAST:event_jb_economicoTodosActionPerformed

    private void jb_ambientalNenhumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_ambientalNenhumActionPerformed
        jli_ambiental.clearSelection();
    }//GEN-LAST:event_jb_ambientalNenhumActionPerformed

    private void jb_socialNenhumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_socialNenhumActionPerformed
        jli_social.clearSelection();
    }//GEN-LAST:event_jb_socialNenhumActionPerformed

    private void jb_economicoNenhumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_economicoNenhumActionPerformed
        jli_economico.clearSelection();
    }//GEN-LAST:event_jb_economicoNenhumActionPerformed

    private void jbt_avancarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbt_avancarActionPerformed

        boolean flagGraficoLinha = false;
        boolean flagGraficoPCA = false;
        ArrayList<String> atributosAmbientaisSelecionados;
        ArrayList<String> atributosSociaisSelecionados;
        ArrayList<String> atributosEconomicosSelecionados;
        ArrayList<retornoBD> listaAtributosPaisesSelecionados = new ArrayList<retornoBD>();

        if (jchb_graficoLinha.isSelected()) {
            flagGraficoLinha = true;
        } else {
            flagGraficoLinha = false;
        }

        if (jchb_graficoPCA.isSelected()) {
            flagGraficoPCA = true;
        } else {
            flagGraficoPCA = false;
        }


        if (flagGraficoLinha == false && flagGraficoPCA == false) {
            JOptionPane.showMessageDialog(null, "Você deve selecionar pelo menos uma opcao entre os gráficos");
        } else {

            atributosAmbientaisSelecionados = getAtributosAmbientaisSelecionados();
            atributosSociaisSelecionados = getAtributosSociaisSelecionados();
            atributosEconomicosSelecionados = getAtributosEconomicosSelecionados();

            for (String pais : listaPaisesSelecionados) {
                for (String atributoAmbiental : atributosAmbientaisSelecionados) {
                    retornoBD objRetornoBdAmbiental = consultas.getAtributoPaisEspecifico(pais, atributoAmbiental).get(0);
                    listaAtributosPaisesSelecionados.add(objRetornoBdAmbiental);                    
                }
                
                for (String atributoSocial : atributosSociaisSelecionados) {
                    retornoBD objRetornoBdSocial = consultas.getAtributoPaisEspecifico(pais, atributoSocial).get(0);
                    listaAtributosPaisesSelecionados.add(objRetornoBdSocial);                    
                }

               for (String atributoEconomico : atributosEconomicosSelecionados) {
                    retornoBD objRetornoBdEconomico = consultas.getAtributoPaisEspecifico(pais, atributoEconomico).get(0);
                    listaAtributosPaisesSelecionados.add(objRetornoBdEconomico);                    
               }
   
            }
            
            if (flagGraficoLinha == true) {
                constroiGraficoLinha(listaAtributosPaisesSelecionados);
            }

            if (flagGraficoPCA == true) {
                constroiGraficoPCA(listaAtributosPaisesSelecionados);
            }
        }
    }//GEN-LAST:event_jbt_avancarActionPerformed

    private void constroiGraficoLinha(ArrayList<retornoBD> objRetornoBD) {

        //Chama grafico linear
        GraficoLinear objgrafico = new GraficoLinear(objRetornoBD);
//        final XYLogAxesDemo demo = objgrafico.new XYLogAxesDemo("Graphic Sustentabilidade");
//        demo.setDefaultCloseOperation(ApplicationFrame.HIDE_ON_CLOSE);
//        demo.pack();
//        RefineryUtilities.centerFrameOnScreen(demo);
//        demo.setVisible(true);

    }

    private void constroiGraficoPCA(ArrayList<retornoBD> objRetornoBD) {
        // chama os bags p/ os metodos PCA lalalalalal
        PCA pca = new PCA(objRetornoBD);
    }

    @Override
    public void dispose() {
        consultas.close();
        super.dispose();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton12;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JButton jb_ambientalDescricao;
    private javax.swing.JButton jb_ambientalNenhum;
    private javax.swing.JButton jb_ambientalTodos;
    private javax.swing.JButton jb_economicoDescricao;
    private javax.swing.JButton jb_economicoNenhum;
    private javax.swing.JButton jb_economicoTodos;
    private javax.swing.JButton jb_socialDescricao;
    private javax.swing.JButton jb_socialNenhum;
    private javax.swing.JButton jb_socialTodos;
    private javax.swing.JButton jbt_avancar;
    private javax.swing.JButton jbt_voltar;
    private javax.swing.JCheckBox jchb_graficoLinha;
    private javax.swing.JCheckBox jchb_graficoPCA;
    private javax.swing.JList jli_ambiental;
    private javax.swing.JList jli_economico;
    private javax.swing.JList jli_paisesSelecionados;
    private javax.swing.JList jli_social;
    // End of variables declaration//GEN-END:variables
}
